<include file="Common/header" />
<title>新建网站角色</title>
</head>
<body>
<div class="pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-user-character-add">
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>所属项目：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="village_id" id="village_id">
						<option value="0">--请选择项目--</option>
						<foreach name="projectlist" item="pro">
						<option value="{$pro.village_id}" {$pro['village_id'] == $info['village_id'] ? 'selected' : ''}>{$pro.project_name}</option>
						</foreach>
					</select>
				</span>
			</div>
			<label class="form-label col-2"><span class="c-red">* </span>费项名称：</label>
			<div class="formControls col-3">
				<input type="text" class="input-text radius" value="{$info['cost_title']}" placeholder="" id="cost_title" name="cost_title" />
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>计费方式：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="cost_type" id="cost_type">
						<option value="0">--请计费方式--</option>
						<?php foreach($costtype as $k=>$val){ ?>
						<option value="{$k}" {$k == $info['cost_type'] ? 'selected' : ''}>{$val}</option>
						<?php } ?>
					</select>
				</span>
			</div>
			<label class="form-label col-2"><span class="c-red">* </span>计费时间：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="cost_begintime" id="cost_begintime">
						<option value="0">--请计费时间--</option>
						<?php foreach($createtime as $k=>$val){ ?>
						<option value="{$k}" {$k == $info['cost_begintime'] ? 'selected' : ''}>{$val}</option>
						<?php } ?>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>费用单价(元)：</label>
			<div class="formControls col-8">
				<input class="input-text radius" placeholder="" id="cost_point" name="cost_point" value="{$info['cost_point']}" />
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>每月生成日期：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="cost_createtime" id="cost_createtime">
					<?php for($i=1;$i<=31;$i++){ ?>
					<option value="{$i}" {$i == $info['cost_createtime'] ? 'selected' : ''}>{$i}</option>
					<?php } ?>
					</select>
				</span>
			</div>
			<label class="form-label col-2"><span class="c-red">* </span>收费周期(月)：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="cost_cycle" id="cost_cycle">
					<?php for($i=1;$i<=12;$i++){ ?>
					<option value="{$i}" {$i == $info['cost_cycle'] ? 'selected' : ''}>{$i}</option>
					<?php } ?>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>滞纳金起算时间(天)：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select class="select radius" name="cost_lastfee_times" id="cost_lastfee_times">
					<?php for($i=1;$i<=31;$i++){ ?>
					<option value="{$i}" {$i == $info['cost_lastfee_times'] ? 'selected' : ''}>{$i}</option>
					<?php } ?>
					</select>
				</span>
			</div>
			<label class="form-label col-2"><span class="c-red">* </span>滞纳金比例(%)：</label>
			<div class="formControls col-3">
				<input type="text" class="input-text radius" value="{$info['cost_latefee']}" placeholder="" id="cost_latefee" name="cost_latefee" />
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">* </span>费项类型：</label>
			<div class="formControls col-8">
				<span class="select-box">
					<select class="select radius" name="cost_intype" id="cost_intype">
						<option value="1" {$i == $info['cost_intype'] ? 'selected' : ''}>固定费项</option>
						<option value="2" {$i == $info['cost_intype'] ? 'selected' : ''}>临时费项</option>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">备注：</label>
			<div class="formControls col-8">
				<input class="input-text radius" placeholder="" id="cost_remark" name="cost_remark" value="{$info['cost_remark']}" />
			</div>
		</div>
		<input type="hidden" id="cost_id" name="cost_id" value="{$info['cost_id']}" />
		<div class="row cl">
			<div class="col-10 col-offset-2">
				<button type="button" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
			</div>
		</div>
	</form>
</div>

<script>
	$(function(){
		$(".btn-success").on('click', function(){
			//验证参数
			if($("#village_id").val() == "0"){
				layer.msg('请选择所属项目', {icon:0, time: {$Think.config.PROMPT_TIME}});
				return false;
			}
			
			var title = $("#cost_title").val() || "";
			if(title.length <= 0){
				layer.msg('请输入收费类型名', {icon:0, time: {$Think.config.PROMPT_TIME}});
				return false;
			}
			
			if($("#cost_type").val() == "0"){
				layer.msg('请选择计费类型', {icon:0, time: {$Think.config.PROMPT_TIME}});
				return false;
			}
			
			if($("#cost_begintime").val() == "0"){
				layer.msg('请选择计费时间', {icon:0, time: {$Think.config.PROMPT_TIME}});
				return false;
			}
			
			//等待效果
			var load = layer.load(2);
			$.post('add.html', $("#form-user-character-add").serialize(), function(msg){
				layer.close(load);
				if(msg == '编辑成功'){
					layer.msg(msg, {icon: 1, time: {$Think.config.PROMPT_TIME}});
					setTimeout(function(){
						window.parent.location.reload(); //刷新
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
						parent.layer.close(index);
					}, {$Think.config.PROMPT_TIME});
				}else{
					layer.msg(msg, {icon: 0, time: {$Think.config.PROMPT_TIME}});
				}
			});
		});
	});
</script>
</body>
</html>